<template>
    <div class="container">
        <div class="header">
            <div class="logo">四川工商学院实验室管理系统</div>
            <div class="user-info">

            </div>
        </div>
        <img class="img1" style="margin-top: -1px" src="../../assets/aa.jpg"/>
        <div class="bigtext">
            <p class="big1">四川工商学院实验室管理系统</p>
            <div class="ms-login animated bounceInLeft">
                <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="0px" class="demo-ruleForm">
                    <el-form-item prop="username">
                        <el-input v-model="ruleForm.username" placeholder="用户名"></el-input>
                    </el-form-item>
                    <el-form-item prop="password">
                        <el-input type="password" placeholder="密码" v-model="ruleForm.password" ></el-input>
                    </el-form-item>
                    <div class="login-btn">
                        <el-button type="primary" @click="login"style="width: 100%;float: left">登录</el-button>
                        <el-button  @click="zhuce" style="width: 100%;float: right">注册</el-button>
                        <el-button @change="" type="text" class="p1"@click="forget">忘记密码?</el-button>
                        <div class="autoLogin">
                            <el-checkbox v-model="checked" style="color:#a0a0a0;">一周内自动登录</el-checkbox>
                        </div>
                    </div>
                </el-form>
            </div>
        </div>
        <div class="bottom1">
            <div class="bottom_text animated bounceInRight">
                <!--<p>-->
                    <!--<img style="height: 100px;width: 100px" src="../../assets/weibo.jpg"/>-->
                    <!--<img style="height: 100px;width: 100px" src="../../assets/weixin.jpg"/>-->
                    <!--<img style="height: 100px;width: 100px" src="../../assets/QQ.jpg"/>-->
                <!--</p>-->
                <p>成都校区：四川省成都市郫都区团结镇学院街65号 邮编：611745</p>
                <p>眉山校区：眉山市眉州大道岷东段9号 邮编：620000</p>
                <p>联系电话    招办：(028)87953080 校办:(028)87953896 人事处：(028)87953900 后勤处：(028)87953092</p>
                <p>Email：yb@stbu.edu.cn</p>
                <p>技术支持QQ群号:644301532 </p>
            </div>
        </div>
    </div>
</template>
<script>

    export default {

        data() {
            return {
                checked : false,
                ruleForm: {
                    username: '',
                    password: ''
                },
                rules: {
                    username: [
                        { required: true, message: '请输入用户名', trigger: 'blur' }
                    ],
                    password: [
                        { required: true, message: '请输入密码', trigger: 'blur' }
                    ]
                },
                outerVisible: false,
                dialogFormVisible:false,
                formLabelWidth: '120px',
                form:{
                    username:'',
                    email:'',
                    tel:'',
                    student_id:'',
                    name:''
                },
                xiuform:{
                    oldpassword:'',
                    newpassword:'',
                    newpassword1:''
                }
            }
        },
        computed:{
            username(){
                let username = localStorage.getItem('ms_username');
                return username ? username : this.form.username;
            }
        },
        methods:{
            zhuce( index,row){
                this.$router.push('/register')
            },
            forget(index,row){
                this.$router.push('/forget')

            },
            denglu(){
                this.$router.push('/login')
            },
            zhuce(){
                this.$router.push('/register')
            },
            //设置cookie
            setCookie: function (cname, cvalue, exdays) {
                var d = new Date();
                d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
                var expires = "expires=" + d.toUTCString();
                console.info(cname + "=" + cvalue + "; " + expires);
                document.cookie = cname + "=" + cvalue + "; " + expires;
                console.info(document.cookie);
            },
            //获取cookie
            getCookie: function (cname) {
                var name = cname + "=";
                var ca = document.cookie.split(';');
                for (var i = 0; i < ca.length; i++) {
                    var c = ca[i];
                    while (c.charAt(0) == ' ') c = c.substring(1);
                    if (c.indexOf(name) != -1) return c.substring(name.length, c.length);
                }
                return "";
            },

            login: function(){
                var sessionId = this.getCookie("sessionId");
                var username1 = this.getCookie("username1");
                var password = this.getCookie("password");
                this.$axios.post('/text/login?'+
                    'username='+this.ruleForm.username+
                    '&password='+this.ruleForm.password
                ).then((res) => {
                    sessionId = res.data.data;
                    if (sessionId != "" && sessionId != null) {
                        this.setCookie("sessionId", sessionId, 10);
                    }
                    if (this.checked == true){
                        username1 = this.ruleForm.username;
                        password = this.ruleForm.password;
                        if (username1 != "" && username1 != null) {
                            this.setCookie("username1", username1, 10);
                        }
                        if (password != "" && password != null) {
                            this.setCookie("password", password, 10);
                        }
                        console.log("aaaaaaaaaaaaaaaaaa");
                    }
                    console.log(document.cookie);
                    if(res.data.code==200)
                        this.$router.push('/readme');
                    else{
                        this.$message.error('登录错误，请检查你的用户名和密码是否正确！！');
                    }
                })
            },

        }
    }
</script>
<style>
    .el-checkbox__input,.el-checkbox__inner,.el-checkbox__label{
        float: left;
    }
</style>
<style scoped>
    p{
        color: #f6faff;
    }
    @media screen and (min-device-width:1200px) {
        .container{
            width: 100%;
            height: 100%;
            overflow: scroll;
        }
        .ms-login{
            width:23%;
            left: 53%;
            top: 55%;
        }
        .p1{
            left: 72%;
        }
        .big1{
            z-index: 1;
            text-align: center;
            color: white;
            font-family:圆体;
            font-size: 55px;
            /*margin-top: 10%;*/
        }
        .bottom_text{
            /*border: red solid 1px;*/
            text-align: center;
            cursor: pointer;
            /*margin-top: 1%;*/
            font-size: 10px;
        }
    }
    @media screen and (min-width: 960px) and (max-width: 1199px) {
        .container{
            width: 100%;
            height: 100%;
            overflow: scroll;
        }
        .ms-login{
            width:33%;
            left: 48%;
            top:40%;
        }
        .p1{
            left: 72%;
        }
        .big1{
            z-index: 1;
            text-align: center;
            color: white;
            font-family:圆体;
            font-size: 45px;
            /*margin-top: 150px;*/

        }
        .p1{
            left: 69%;
        }
        .bottom_text{
            /*border: red solid 1px;*/
            text-align: center;
            cursor: pointer;
            /*margin-top: 5%;*/
        }
    }
    @media screen and (min-width: 768px) and (max-width: 959px){
        .container{
            width: 100%;
            height: 100%;
            overflow: scroll;
        }
        .ms-login{
            width:35%;
            left: 47%;
            top: 25%;
        }
        .p1{
            left: 72%;
        }
        .big1{
            z-index: 1;
            text-align: center;
            color: white;
            font-family:圆体;
            font-size: 35px;
            /*margin-top: 150px;*/
        }
        .bottom_text{
            /*border: red solid 1px;*/
            text-align: center;

            cursor: pointer;
            /*margin-top: 12%;*/
            font-size: 10px;
        }
    }
    @media screen and (min-width: 480px) and (max-width: 767px) {
        .container{
            width: 100%;
            height: 100%;
            overflow: scroll;
        }
        .ms-login{
            width:45%;
            left: 40%;
            top: 25%;
        }
        .big1{
            z-index: 1;
            text-align: center;
            color: white;
            font-family:圆体;
            font-size: 30px;
            /*margin-top: 150px;*/
        }
        .p1{
            left: 57%;
        }
        .bottom_text{
            /*border: red solid 1px;*/
            text-align: center;
            cursor: pointer;
            /*margin-top: 30%;*/
            font-size: 10px;
        }
    }
    @media screen and (max-width: 479px){
        .container{
            width: 100%;
            height: 100%;
            overflow: scroll;
        }
        .ms-login{
            width: 76%;
            left: 19%;
            top: 20%;
        }
        .p1{
            left: 72%;
        }
        .big1{
            z-index: 1;
            text-align: center;
            color: white;
            font-family:圆体;
            font-size: 30px;
            /*margin-top: 100px;*/
        }
        .bottom_text{
            /*border: red solid 1px;*/
            text-align: center;
            cursor: pointer;
            /*margin-top: 50%;*/
            font-size: 10px;
        }
    }
    .bottom1{
        position:relative;
        font-size: 16px;
        overflow: hidden;
        /*margin-top:16%;*/
        width: 100%;
    }

    .bottom_img{
        position: absolute;
        right: 50%;
        margin-top: 20px;
        width: 600px;
        background-color: #f6faff;
    }

    .ms-login{
        position: relative;
        /*left:53%;*/
        /*top:40%;*/
        /*margin: 0 auto;*/
        /*width:23%;*/
        height:47%;
        margin:-15% 0 0 -19%;
        padding:40px;
        border-radius: 5px;
        background: #fff;
    }
    .big1{
        margin-top: 5%;
    }
    .autoLogin label{
        float: left;
        height: 18px;
        overflow: hidden;
    }
    .login-btn{
        text-align: center;
    }
    .login-btn button{
        width:100%;
        height:40px;
    }
    .p1{
        position: relative;
        margin-top: 10px;
        float: left;
        /*left: 20%;*/
        padding-right: 230px;
    }


    .bigtext{
        z-index: 1;
        text-align: center;
        color: #dddddd;
        font-family:圆体;
        font-size: 80px;
        /*margin-top: 100px;*/
        /*border: 1px solid red;*/
        height:500px;
    }
    .img1
    {
        position:absolute;
        height: 100%;
        width: 100%;
        left:0px;
        top:0px;
        z-index:-1;
    }
    .btntext{
        position: absolute;
        width:300px;
        height: 100px;
        line-height: 100px;
        top:430px;
        left: 50%;
        margin-left: -85px;
        font-size: 56px;
        border: 2px solid #dddddd;
        border-radius: 3px;
        text-decoration: none;
        text-align: center;
        font-family: 宋体;
    }
    .header {
        position: relative;
        box-sizing: border-box;
        width: 100%;
        height: 70px;
        font-size: 22px;
        line-height: 70px;
        color: #fff;
    }
    .header .logo{
        float: left;
        width:310px;
        text-align: center;
        /*font-size: 16px;*/
    }
    .user-info {
        float: right;
        padding-right: 50px;
        font-size: 16px;
        color: #fff;
    }
    .user-info .el-dropdown-link{
        position: relative;
        display: inline-block;
        padding-left: 50px;
        color: #fff;
        cursor: pointer;
        vertical-align: middle;
    }
    .user-info .user-logo{
        position: absolute;
        left:0;
        top: 15px;
        width:40px;
        height:40px;
        border-radius: 50%;
    }
    .el-dropdown-menu__item{
        text-align: center;
    }
</style>
